#pragma once

#include "ui_mainwindow.h"

#include <QMainWindow>
#include <QTimer>
#include <opencv2/opencv.hpp>

namespace MISystem
{
    class MainWindow : public QMainWindow
    {
        Q_OBJECT

    public:
        MainWindow(QWidget* parent = nullptr);
        ~MainWindow();

    private slots:
        void on_startButton_clicked();
        void on_stopButton_clicked();
        void on_checkButton_clicked();
        void on_refreshStockButton_clicked();
        void on_refreshOperationButton_clicked();
		void on_generateExcelButton_clicked();
        void processFrame();

    private:
        void setupTab1();
        void setupTab2();
        void setupTab3();
        void setupTab4();

        void refreshStockTable();
        void refreshOperationTable();
        void updateStockBarChart();

        QImage cvMatToQImage(const cv::Mat& mat);

    private:
        cv::VideoCapture _cap;
        cv::QRCodeDetector _qrDecoder;
        QTimer* _timer;

        QString _decodedText;

    private:
        Ui::MainWindowClass* ui;
    };
}
